import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class GamepadWombat here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class GamepadWombat extends Actor
{
    private static final GamePad.Button BUTTON_USE_SPECIAL = GamePad.Button.ACTION_DOWN;
    private static final GamePad.Button SHOOT_BUTTON = GamePad.Button.R1;

   private GamePad pad;
    
    /**
     * Act - do whatever the GamepadWombat wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if(pad==null) pad = GamePad.getGamePad();
        
        
        if (isShooting()) System.out.println("Peng!"+pad);
        if (pad.isButtonSupported(SHOOT_BUTTON)) System.out.println("jupp.");
    }    
    
      private boolean hasGamePad()   
    {
        return pad != null;
    }
    
        private boolean isShooting()
    {
        return Greenfoot.isKeyDown("space") || (pad.isDown( BUTTON_USE_SPECIAL ));
    }
}
